package com.abel.roommanager.mapper;


import java.util.List;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.abel.roommanager.pojo.Role;
import com.abel.roommanager.pojo.User;

public interface UserMapper {
    @Select("select * from user where username=#{username}")
	User findUserByUserName(String username);
    @Select("select * from user where username=#{username}")
    @Results({
    	@Result(id=true,column="id",property="id"),
    	@Result(column="id",property="roles",many=@Many(
    			select="findRolesByUid"
    			
    			))
    	
    })
	User findUserRolesByUsername(String username);
    @Select("select * from role r,user_role ur where r.rid=ur.rid and ur.uid=#{id}")
  List<Role>  findRolesByUid(String id);

}
